using System;
using System.Collections.Generic;
using System.Text;
using MDK;

namespace ThompsonScatteringLib
{
    class MovingParticle : Particle
    {
        double r = 0;
        double f = 0;
        double fx = 0;
        double fy = 0;

        double ay = 0;
        double ax = 0;

        double fi = 0;
        double dx = 0;
        double dy = 0;

        
        public MovingParticle(){}
        

        #region Counting
        public void Move(Particle Nucl)
        {
            dx = Math.Abs(Nucl.x - this.x);
            dy = Math.Abs(Nucl.y - this.y);

            r = Math.Sqrt((dx * dx + dy * dy));

            fi = Math.Asin(dy / r);

            f =  1E+8 * (Nucl.Q * this.Q) / (4 * Math.PI * 8.85 * r * r);

            fx = (float)f * (float)Math.Cos((double)fi);
            fy = (float)f * (float)Math.Sin((double)fi);

            ax = 100 * fx / this.m;
            ay = 100 * fy / this.m;

            this.vy += ay;
            this.y -= (float)this.vy;

            this.vx += ax;
            this.x  += (float)this.vx;

        }
        #endregion

    }
}
